#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    FILE* fp = fopen("./data.in", "r");
    int target, nums;  //目标值 物品数
    while (fscanf(fp, "%d%d", &target, &nums) != EOF) {
        int* dp = (int*)malloc((target + 1) * sizeof(int));
        int* containers = (int*)malloc(nums * sizeof(int));
        for (int i = 0; i < nums; i++) {
            fscanf(fp, "%d", &containers[i]);
        }
        for (int i = 0; i < nums; i++) {
            for (int j = target; j >= containers[i]; j--) {
                dp[j] += dp[j - containers[i]];
            }
            dp[containers[i]]++;
        }
        printf("%d\n", dp[target]);
    }
}